﻿module;

#include <boost/asio.hpp>
#include <boost/beast.hpp>

export module Main;
import std;
import Main_config;
import IIS_lisenter_str;
import IIS_log_str;
import MySQL_run;

import SchoolMysqlShowTable;
import SchoolDataBaseTestStruct;
import SchoolMysqlAddStruct;
import SchoolMysqlGetStruct;

void runConfig() {
	std::jthread th_IIS(
		[]() {
			if (Main_config::runIIS == true) {
				try {
					IIS_lisenter_str::Server server(9095);
					IIS_log_str::Log::runRouter();
					server.start();
				}
				catch (std::exception e) {
					std::cerr << e.what() << std::endl;
				}
			}
		}
	);

	std::jthread th_MySQL(
		[]() {
			if (Main_config::runMySQL == true) {
				try {
					MySQL_run::Run run;
					//run.start();
					//SchoolMysqlShowTable::createTables();
					SchoolMysqlAddStruct::insertTable(SchoolDataBaseTestStruct::Table(1, "T1", 4, "Room A", "Available", 1700000000, 1700000000, false, "TestTest"));
					SchoolMysqlAddStruct::insertCustomer(SchoolDataBaseTestStruct::Customer(1, "John Doe", "1234567890", "213", 231, 2323.24, 1700000000, "Test2", { 1,2,3,4 }));
					SchoolMysqlAddStruct::insertOrder(SchoolDataBaseTestStruct::Order(1, 1, 1, "ORD20250619001", "Pending", 1700000000, 1700000000, 100.00, 10.00, "Cash", "No remarks"));
					SchoolMysqlShowTable::checkTables();
					//SchoolMysqlGetStruct::getAllTables();
					SchoolMysqlGetStruct::test();
				}
				catch (std::exception e) {
					std::cerr << e.what() << std::endl;
				}
			}
		}
	);
}

export int main() {
	runConfig();
}